#!/bin/bash

CURDIR="$PWD"

exec docker run \
  --rm \
  -it \
  -e HOME -v "${HOME}:${HOME}" \
  -e USER \
  -u "$(id -u):$(id -g)" \
  $(id -Gz | xargs -0 -n1 -I{} echo "--group-add={}") \
  -v /etc/passwd:/etc/passwd:ro \
  -v /dev/bus/usb:/dev/bus/usb \
  -v "${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}" \
  -e SSH_AUTH_SOCK \
  --privileged \
  -h rock64-build-env \
  -v "${CURDIR}:${CURDIR}" \
  -w "${CURDIR}" \
  ayufan/rock64-dockerfiles:x86_64 \
  "$@"
